<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('问卷分配问题')" />
</head>
<body>
<div class="main-content">
    <form id="form-user-add" class="form-horizontal">
        <h4 class="form-header h4">基本信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">问卷id：</label>
                    <div class="col-sm-8">
                        <input id="questionnaireId" name="questionnaireId" class="form-control" type="text" disabled th:value="${questionnaire.id}">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">问卷状态：</label>
                    <div class="col-sm-8">
                        <input name="status" class="form-control" type="text" disabled th:value="${questionnaire.status}">
                    </div>
                </div>
            </div>

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">问题内容：</label>
                    <div class="col-sm-8">
                        <input name="personType" class="form-control" type="text" disabled th:value="${questionnaire.personType}">
                    </div>
                </div>
            </div>
        </div>

        <h4 class="form-header h4">分配问题</h4>
        <div class="row">
            <div class="col-sm-12">
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </form>
</div>

<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "question/compose/authInfo";
    var questionInfoList = [[${questionInfoList}]]

    $(function() {
        var options = {
            data: questionInfoList,
            sidePagination: "client",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            clickToSelect: true,
            maintainSelected: true,
            columns: [{
                checkbox: true,
                formatter:function (value, row, index) {
                    if($.common.isEmpty(value)) {
                        return { checked: row.flag };
                    } else {
                        return { checked: value }
                    }
                }
            },
            {
                field: 'id',
                title: '问题编号'
            },
            {
                field: 'content',
                title: '问题内容'
            }]
        };
        $.table.init(options);
    });

    /* 添加角色-提交 */
    function submitHandler(index, layero){
        var rows = $.table.selectFirstColumns();
        var data = {"questionnaireId":$('#questionnaireId').val(),"Ids": rows.join() };
        $.operate.saveTab(prefix + "/insertAuthInfo", data);
    }
</script>
</body>
</html>